package leecode

func findDifference(nums1 []int, nums2 []int) (result [][]int) {
	hashMap1 := make(map[int]int)
	for i := 0; i < len(nums1); i++ {
		hashMap1[nums1[i]] = 1
	}
	answer1 := make([]int, 0)
	answer2 := make([]int, 0)
	for i := 0; i < len(nums2); i++ {
		if _, ok := hashMap1[nums2[i]]; !ok {
			answer2 = append(answer2, nums2[i])
		}
		hashMap1[nums2[i]]++
	}
	visited := make(map[int]bool)
	for i := 0; i < len(nums1); i++ {
		if visited[nums1[i]] {
			continue
		}
		if hashMap1[nums1[i]] == 1 {
			answer1 = append(answer1, nums1[i])
		}
		visited[nums1[i]] = true
	}
	result = append(result, answer1)
	result = append(result, answer2)
	return

}
